<?php
/* 
* @Author: Administrator
* @Date:   2014-07-23 22:22:53
* @Last Modified by:   Administrator
* @Last Modified time: 2014-07-25 00:00:47
*/

/**
* 简历职位中间表
*/
class ResumePosModel extends Model
{
	public $table = 'relation_resume2_pos';


	public function add_data($reid)
	{
		$posid = Q('post.posid');
		if (count($posid)>6) {
			$this->error = '最多6个期望岗位';
			return false;
		}
		$data=array();
		foreach ($posid as $v) {
			$data[]=array('re_posid'=>$v,'re_reid'=>$reid);
		}
		// p($data);exit;
		return $this->addAll($data);
	}


	public function get_data($resume1_reid)
	{
		$res = $this->where('re_reid = '.$resume1_reid)->all();
		$temp =array();
		foreach ($res as $value) {
			$temp[] = $value['re_posid'];
		}
		// p($temp);
		return $temp;
	}


	public function update_data($reid)
	{
		$posid = Q('post.posid');
		if (count($posid)>6) {
			$this->error = '最多6个期望岗位';
			return false;
		}
		$this->where(array('re_reid'=>$reid))->delete();
		$data=array();
		foreach ($posid as $v) {
			$data=array('re_posid'=>$v,'re_reid'=>$reid);
			$this->add($data);
		}

		return true;
	}

	public function del_data($reid){
		$this->where(array('re_reid'=>$reid))->delete();
	}
}
?>
